package com.skymxc.wandroidtodo.page.add;

import android.app.Application;

import androidx.annotation.NonNull;

import com.skymxc.wandroidtodo.data.net.NetObserver;
import com.skymxc.wandroidtodo.entity.TODOItem;
import com.skymxc.wandroidtodo.page.base.BasePresenter;

/**
 * <p>
 *
 * </p>
 *
 * @author 孟祥超
 * <p>
 * date: 2021/12/3  7:23 上午
 */
class AddItemPresenter extends BasePresenter<AddItemContact.AddItemView> implements AddItemContact.IAddItemPresenter {
    public AddItemPresenter(Application application) {
        super(application);
    }

   private AddItemModel addItemModel = new AddItemModel();

    @Override
    public void addItem(String title, String content) {
        view.showProgress("添加中");
        addItemModel.addItem(title, content)
                .subscribe(new NetObserver<TODOItem>(compositeDisposable, view) {
                    @Override
                    public void onNext(@NonNull TODOItem item) {
                        view.addSuccess();
                    }
                });
    }
}
